package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TemperatureSensor;
import com.ruoyi.system.service.ITemperatureSensorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 温度传感器数据Controller
 * 
 * @author ruoyi
 * @date 2025-10-28
 */
@RestController
@RequestMapping("/system/temperatureSensor")
public class TemperatureSensorController extends BaseController
{
    @Autowired
    private ITemperatureSensorService temperatureSensorService;

    /**
     * 查询温度传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:temperatureSensor:list')")
    @GetMapping("/list")
    public TableDataInfo list(TemperatureSensor temperatureSensor)
    {
        startPage();
        List<TemperatureSensor> list = temperatureSensorService.selectTemperatureSensorList(temperatureSensor);
        return getDataTable(list);
    }

    /**
     * 导出温度传感器数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:temperatureSensor:export')")
    @Log(title = "温度传感器数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TemperatureSensor temperatureSensor)
    {
        List<TemperatureSensor> list = temperatureSensorService.selectTemperatureSensorList(temperatureSensor);
        ExcelUtil<TemperatureSensor> util = new ExcelUtil<TemperatureSensor>(TemperatureSensor.class);
        util.exportExcel(response, list, "温度传感器数据数据");
    }

    /**
     * 获取温度传感器数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:temperatureSensor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(temperatureSensorService.selectTemperatureSensorById(id));
    }

    /**
     * 新增温度传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:temperatureSensor:add')")
    @Log(title = "温度传感器数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TemperatureSensor temperatureSensor)
    {
        return toAjax(temperatureSensorService.insertTemperatureSensor(temperatureSensor));
    }

    /**
     * 修改温度传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:temperatureSensor:edit')")
    @Log(title = "温度传感器数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TemperatureSensor temperatureSensor)
    {
        return toAjax(temperatureSensorService.updateTemperatureSensor(temperatureSensor));
    }

    /**
     * 删除温度传感器数据
     */
    @PreAuthorize("@ss.hasPermi('system:temperatureSensor:remove')")
    @Log(title = "温度传感器数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(temperatureSensorService.deleteTemperatureSensorByIds(ids));
    }
}
